#include "processbar.h"
#include <string.h>
#include <unistd.h>
const char* lable = "|/-\\";
 char buffer[MAX] = {0};
void process(double rate)
{
        static int cnt = 0;
        int n = strlen(lable);
        if(rate <= 1.0)
            buffer[0] = Head;
        printf("[%-100s][%.1f%%][%c]\r",buffer,rate,lable[cnt%n]);
        fflush(stdout);
        buffer[(int)rate] = Body;
        if((int)rate < 100)
            buffer[(int)rate+1] = Head;
        if(rate >= 100.0)
            printf("\n");

        cnt++;
        cnt %= n;
}
